cmake_minimum_required(VERSION 3.5)

project(Previewer LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

IF (UNIX)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-pthread")
ENDIF(UNIX)

cmake_policy(SET CMP0074 NEW)
add_compile_options(-Wno-narrowing -Wcpp -Wno-attributes)

add_compile_definitions(ASIO_STANDALONE)
add_compile_definitions(_WEBSOCKETPP_CPP11_STL_)
IF (UNIX)
add_compile_definitions(FEATURE_ACELITE_MC_LOG_PRINTF)
ENDIF(UNIX)

#if(MSVC)
	add_compile_definitions(ASIO_HAS_STD_TYPE_TRAITS)
	add_compile_definitions(ASIO_HAS_STD_SHARED_PTR)
	add_compile_definitions(ASIO_HAS_STD_ADDRESSOF)
	add_compile_definitions(ASIO_HAS_STD_ATOMIC)
	add_compile_definitions(ASIO_HAS_STD_CHRONO)
	add_compile_definitions(ASIO_HAS_CSTDINT)
	add_compile_definitions(ASIO_HAS_STD_ARRAY)
	add_compile_definitions(ASIO_HAS_STD_SYSTEM_ERROR)
#endif(MSVC)

include_directories("./cxxopts")
include_directories("./asio")
include_directories("./websocketpp")
include_directories("./inc")
include_directories("./asio/include")
include_directories("./cJSON")
include_directories("./")
include_directories("./inc/device")
include_directories("./inc/jsapp")
include_directories("./inc/mock")
include_directories("./Harmony/inc/aafwk")
include_directories("./Harmony/inc/aafwk/interfaces/kits/ability_lite")
include_directories("./Harmony/inc/base/global/interfaces/innerkits/resmgr_lite")
include_directories("./Harmony/inc/base/startup/frameworks/syspara_lite/parameter/src")
include_directories("./Harmony/inc/base/startup/hals/syspara_lite")
include_directories("./Harmony/inc/base/startup/interfaces/kits/syspara_lite")
include_directories("./Harmony/inc/graphic/frameworks/surface/include")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/common")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/core")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/default_resource")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/dfx")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/dock/ohos")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/draw")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/font")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/imgdecode")
include_directories("./Harmony/inc/graphic/frameworks/ui/include/window")
include_directories("./Harmony/inc/graphic/hals/include")
include_directories("./Harmony/inc/graphic/interfaces/innerkits/ui/common")
include_directories("./Harmony/inc/graphic/interfaces/innerkits/ui/dock")
include_directories("./Harmony/inc/graphic/interfaces/wms/common")
include_directories("./Harmony/inc/graphic/interfaces/kits/config")
include_directories("./Harmony/inc/graphic/interfaces/kits/surface")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/animator")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/common")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/components")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/dfx")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/events")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/font")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/layout")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/themes")
include_directories("./Harmony/inc/graphic/interfaces/kits/ui/window")
include_directories("./Harmony/inc/graphic/interfaces/kits/utils")
include_directories("./Harmony/inc/graphic/services/ims/include")
include_directories("./Harmony/inc/graphic/services/wms/include/client")
include_directories("./Harmony/inc/graphic/services/wms/include/server")
include_directories("./Harmony/inc/graphic/utils/include")
include_directories("./Harmony/inc/js/builtin/common/include")
include_directories("./Harmony/inc/js/builtin/deviceinfokit/include")
include_directories("./Harmony/inc/js/builtin/filekit/include")
include_directories("./Harmony/inc/js/builtin/kvstorekit/include")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/include/base")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/include/context")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/include/resource")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/modules")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/animation")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/base")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/context")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/components")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/jsi/internal")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/src/core/router")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/targets")
include_directories("./Harmony/inc/jsfwk/frameworks/lite/targets/simulator/win")
include_directories("./Harmony/inc/jsfwk/interfaces/innerkits/builtin/async")
include_directories("./Harmony/inc/jsfwk/interfaces/innerkits/builtin/base")
include_directories("./Harmony/inc/jsfwk/interfaces/innerkits/builtin/jsi")
include_directories("./Harmony/inc/jerry")
include_directories("./Harmony/inc/jerry/jerry-ext/include")
include_directories("./Harmony/inc/jerry/jerry-core/include")
include_directories("./Harmony/inc/bounds_checking_function/include")
include_directories("./Harmony/inc/appexecfwk/interfaces/kits/bundle_lite")
include_directories("./Harmony/inc/aafwk/interfaces/kits/want_lite")
include_directories("./Harmony/inc/communication/interfaces/kits/ipc_lite")
include_directories("./Harmony/inc/appexecfwk/utils/bundle_lite")
include_directories("./Harmony/inc/js/builtin/common/include")
include_directories("./Harmony/inc/js/builtin/deviceinfokit/include")
include_directories("./Harmony/inc/js/builtin/filekit/include")
include_directories("./Harmony/inc/js/builtin/kvstorekit/include")
include_directories("./Harmony/inc/freetype")
include_directories("./Harmony/inc/js/builtin/deviceinfokit/include")

file(GLOB Server_SRC
    "src/*.cpp"
)

aux_source_directory(src/jsapp jsapp_src)
aux_source_directory(src/mock mock_src)
aux_source_directory(src/utils utils_src)
link_directories(Harmony/lib)

add_executable(Previewer main.cpp ${Server_SRC} cJSON/cJSON.c ${jsapp_src} ${mock_src} ${utils_src})
target_link_libraries(Previewer -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread libutils_jsapi.a libjsfwk.a liblibjpeg.a liblibpng.a libui.a libzlib.a libfreetype.a libjerry-core.a libjerry-ext.a libjerry-port-default.a)

IF(UNIX)
	# libbcfunc: bounds_checking_function
	target_link_libraries(${CMAKE_PROJECT_NAME} liblibbcfunc.a -Wl,-Bdynamic -lpthread)
ENDIF(UNIX)

IF(MINGW)
        target_link_libraries(${CMAKE_PROJECT_NAME} libws2_32.a libmswsock.a shlwapi.a)
ENDIF(MINGW)

